﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tramthuphi
{
    class Program
    {
        static void Main(string[] args)
        {
            trthuphi ttp = new trthuphi();

            ConsoleKeyInfo k;
    
            //--- Xay dung menu ------
            for (int i = 0; i < 5; i++)
                Console.WriteLine();

            Console.WriteLine("CHUONG TRINH TINH PHI GIAO THONG");
            Console.WriteLine();
            Console.WriteLine("1.Xe qua tram phai tra phi, nhan phim P ");
            Console.WriteLine("2.Xe qua tram khong phai tra phi, nhan phim U ");
            Console.WriteLine("3.Nhan phim ESC de thoat chuong trinh");

            do 
            {
                Console.WriteLine();
                Console.Write("Nhan phim: ");
                k = Console.ReadKey();

                if (k.Key == ConsoleKey.P)
                {
                    ttp.demxett();
                    Console.WriteLine("SO luong xe tra tien da qua tram: "+ttp.get_slx_tratien());
                }
                else if (k.Key == ConsoleKey.U)
                {
                    ttp.demxektt();
                    Console.WriteLine("so luong xe khong phai tra tien"+ttp.get_slx_ktratien());
                }
                else if (k.Key == ConsoleKey.Escape)
                {
                    Console.WriteLine("Thoat chuong trinh");
                    Console.WriteLine("Tong so xe qua tram: "+ttp.get_tongxequa());
                    Console.WriteLine("Tong tien thu duoc: "+ttp.tinhtongtien());
                }
                else
                {
                    Console.WriteLine("Nhap khong dung ki tu, xin nhap lai");
                }
            }while(k.Key != ConsoleKey.Escape);

            Console.ReadKey();
        }

    }
    class trthuphi
    {
        //du lieu
        private int slx_tratien;
        private int slx_ktratien;
        private int tongtien;
        //private int tongxequa;
        //hanh vi
        //ham tao
        public trthuphi()
        {
            slx_tratien = 0;
            slx_ktratien = 0;
            tongtien = 0;
            //tongxequa = 0;
        }
        public trthuphi(int tt,int ktt,int tongt,int txq)
        {
            slx_tratien = tt;
            slx_ktratien = ktt;
            tongtien = tongt;
            //tongxequa = txq;
        }
        //lay du lieu
        public int get_slx_tratien()
        {
            return slx_tratien;
        }
        public int get_slx_ktratien()
        {
            return slx_ktratien;
        }
        public int get_tongtien()
        {
            return tongtien;
        }
        public int get_tongxequa()
        {
            return slx_tratien+slx_ktratien;
        }


        public void demxett()
        {
            slx_tratien++;
        }
        public void demxektt()
        {
            slx_ktratien++;
        }
        public int tinhtongtien()
        {
            return 10000 * slx_tratien;
        }      
    }
}
